/**
 * 完美转发
 */
#include <iostream>
#include <utility>

template<typename T>
void print(T &t) {
    std::cout << "lhs value: " << t << std::endl;
}

template<typename T>
void print(T &&t) {
    std::cout << "rhs value: " << t << std::endl;
}

template<typename T>
void test_forward(T &&v) {     // 引用折叠
    print(v);                  // 左值
    print(std::forward<T>(v)); // 看参数转发
    print(std::move(v));       // 右值
}

int main(int argc, char *argv[]) {
    test_forward(1); // 入参为右值

    std::cout << "======================" << std::endl;

    int x = 1;
    test_forward(x); // 入参为左值
}